package com.jacen.fzxs.entity.web;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import com.jacen.fzxs.entity.WallEntity;
import com.jacen.fzxs.util.LocationUtil;

public class Wall {

	private String id;
	private String userName;
	private String tel;
	private String address;
	private String province;// 省
	private String city;// 市
	private String district; // 县
	private String lon;
	private String lat;
	private String area;
	private String width;
	private String high;
	private String price;
	private List<String> images;

	public String getId() {
		return id;
	}

	public void setId(String id) {
		this.id = id;
	}

	public String getUserName() {
		return userName;
	}

	public void setUserName(String userName) {
		this.userName = userName;
	}

	public String getTel() {
		return tel;
	}

	public void setTel(String tel) {
		this.tel = tel;
	}

	public String getAddress() {
		return address;
	}

	public void setAddress(String address) {
		this.address = address;
	}

	public String getLon() {
		return lon;
	}

	public void setLon(String lon) {
		this.lon = lon;
	}

	public String getLat() {
		return lat;
	}

	public void setLat(String lat) {
		this.lat = lat;
	}

	public String getArea() {
		return area;
	}

	public void setArea(String area) {
		this.area = area;
	}

	public String getPrice() {
		return price;
	}

	public void setPrice(String price) {
		this.price = price;
	}

	public List<String> getImages() {
		return images;
	}

	public void setImages(List<String> images) {
		this.images = images;
	}

	public String getWidth() {
		return width;
	}

	public void setWidth(String width) {
		this.width = width;
	}

	public String getHigh() {
		return high;
	}

	public void setHigh(String high) {
		this.high = high;
	}

	public String getProvince() {
		return province;
	}

	public void setProvince(String province) {
		this.province = province;
	}

	public String getCity() {
		return city;
	}

	public void setCity(String city) {
		this.city = city;
	}

	public String getDistrict() {
		return district;
	}

	public void setDistrict(String district) {
		this.district = district;
	}

	public static List<Wall> turnToWallList(List<WallEntity> list) {
		List<Wall> walls = new ArrayList<Wall>();
		for (WallEntity entity : list) {
			walls.add(turnToWall(entity));
		}
		return walls;
	}

	public static Wall turnToWall(WallEntity entity) {
		Wall wall = new Wall();
		wall.setId(entity.getId());
		wall.setAddress(entity.getProvince() + entity.getCity() + entity.getCounty() + entity.getAddress());
		wall.setUserName(entity.getUsername());
		wall.setTel(entity.getTel());
		Map<String, Double> locationMap = LocationUtil.getLngAndLat(wall.getAddress());
		wall.setLat(
				entity.getLocationY() == null ? locationMap.get("lat").toString() : entity.getLocationY().toString());// 纬度
		wall.setLon(
				entity.getLocationX() == null ? locationMap.get("lng").toString() : entity.getLocationX().toString());// 经度
		wall.setArea(entity.getArea());
		wall.setPrice(entity.getPrice());
		return wall;
	}
}
